package com.problem.leetcode;

/**
 * @author yanzhuoleo
 * @version V1.0
 * @Description: Problem88
 * @date 2018-01-15-下午3:57
 */

public class Problem88 {
    public void merge(int[] nums1, int m, int[] nums2, int n) {
        int lastIndex1 = m - 1;
        int lastIndex2 = n - 1;
        int length     = m + n - 1;

        while (lastIndex1 >= 0 && lastIndex2 >= 0) {
            if (nums1[lastIndex1] >= nums2[lastIndex2]) {
                nums1[length--] = nums1[lastIndex1--];
            } else {
                nums1[length--] = nums2[lastIndex2--];
            }
        }

        while (lastIndex2 >= 0) {
            nums1[length--] = nums2[lastIndex2--];
        }
    }
}
